package com.cdvtc.news.web.admin;

import com.cdvtc.news.service.NewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller("adminIndexController")
@RequestMapping("/admin")
public class IndexController {

    @Autowired
    NewsService newsService;

    @RequestMapping
    public String index(){
        return "admin/index";
    }

    @RequestMapping("/stat/newsCountByCategory")
    @ResponseBody
    public List<Map<String, Object>> newsCountByCategory(){
        return newsService.statNewsCountByCategory();
    }

    @RequestMapping("/stat/newsCountByTag")
    @ResponseBody
    public List<Map<String, Object>> statNewsCountByTag() {
        return newsService.statNewsCountByTag();
    }

    @RequestMapping("/stat/newsCommentCountByDate")
    @ResponseBody
    public List<Map<String, Object>> statNewsCommentCountByDate() {
        return newsService.statNewsCommentCountByDate();
    }

    @RequestMapping("/stat/newsCommentCountByUser")
    @ResponseBody
    public List<Map<String, Object>> statNewsCommentCountByUser() {
        return newsService.statNewsCommentCountByUser();
    }
}
